//821. 字符的最短距离
//思路：一静一动来找每个字符与特定字符c的距离

#include <stdlib.h>
#include <string.h>
#include <math.h>
int* shortestToChar(char * s, char c, int* returnSize){
    int len = strlen(s);
    *returnSize = len;
    int* ret = (int*)malloc(sizeof(int)*len);
    int min = INT_MAX;

    for(int i = 0; i < len; i++)
    {
        for(int j = 0; j < len; j++)
        {
            if(s[j] == c)
            {
                min = fmin(min, abs(i-j));
            }
        }
        ret[i] = min;
        min = INT_MAX;//存入后更新min，防止重复
    }

    return ret;
}